import React, { Component } from 'react';

import './index.less';
import HROrgReger from '../../../../../hrpub/common/components/referSearch/org';






class Header extends Component {
    constructor(props) {
        super(props);
        this.buttonClickHandle = this.buttonClickHandle.bind(this);
        this.handleHumanOrgTreeChange = this.handleHumanOrgTreeChange.bind(this);
        this.state ={
            humanResourceOrganizationValue:{}
        }
    }
    buttonClickHandle(props, btnCode){
        switch (btnCode) {
            case 'add':  // 新增
                this.props.addOperation();
                break;
            case 'edit':  // 编辑
                this.props.editOperation();
                break;
            case 'delete':  // 删除
                this.props.deleteOperation();
                break;
            case 'query':  // 查询
                this.props.searchOperation();
                break;
            case 'save':  // 保存
                this.props.saveOperation();
                break;
            case 'cancel':  // 取消
                this.props.cancelOperation();
                break;
            case 'refresh':  // 刷新
                this.props.refreshOperation();
                break;
            default:
                break;
        }
        
    }
    handleHumanOrgTreeChange(value){
        this.setState({ humanResourceOrganizationValue: value });
        this.props.handleHumanOrgTreeChange(value)
    }
    render() {
        const {
            button,
        } = this.props;
        return (
            <div className="header nc-bill-header-area">
                <div className="search-refer">
                    {this.props.flagBut === false?(
                         <HROrgReger
                         getOrgData={this.handleHumanOrgTreeChange}
                         orgVal={this.state.humanResourceOrganizationValue}
                         queryCondition={()=>{
                            return {"TreeRefActionExt": "nccloud.web.hrjf.managescope.sqlbulider.HROrgTreeRefSqlBuilder"}
                         }}
                         />
                    ):null}
                   
                </div>
                <div className="btn-group">
                    <div className="definition-icons">
                        {button.createButtonApp({
                            area: 'head',
                            onButtonClick: this.buttonClickHandle
                        })}
                    </div>
                </div>
            </div>
        );
    }
}

export default Header;
